﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.InteropServices;

namespace Deep_Talk_Converter.ProcessPriorityUtils
{
    /// <summary>
    /// P/Invoke defs stolen from
    /// http://code.logos.com/blog/2008/10/using_background_processing_mode_from_c.html
    /// </summary>
    internal static class Win32
    {
        public const int THREAD_MODE_BACKGROUND_BEGIN = 0x00010000;
        public const int THREAD_MODE_BACKGROUND_END = 0x00020000;

        public const int PROCESS_MODE_BACKGROUND_BEGIN = 0x00100000;
        public const int PROCESS_MODE_BACKGROUND_END = 0x00200000;
    }

    internal static class NativeMethods
    {
        [DllImport("Kernel32.dll", ExactSpelling = true)]
        public static extern IntPtr GetCurrentThread();

        [DllImport("Kernel32.dll", ExactSpelling = true)]
        public static extern IntPtr GetCurrentProcess();

        [DllImport("Kernel32.dll", ExactSpelling = true)]
        [return: MarshalAs(UnmanagedType.Bool)]
        public static extern bool SetThreadPriority(IntPtr hThread, int nPriority);

        [DllImport("Kernel32.dll", ExactSpelling = true)]
        [return: MarshalAs(UnmanagedType.Bool)]
        public static extern bool SetPriorityClass (IntPtr hProcess, int nPriorityClass);
    }
}
